package cn.gxljc.technology.store_management.mapper;

import cn.gxljc.technology.store_management.entity.Ware;
import org.apache.ibatis.annotations.*;

/*
 **@author LuoShengYing
 **@date 2021/6/18
 * WareMapper用于管理Ware(商品)类
 */
@Mapper
public interface WareMapper {

    // 通过商品ID查询商品信息
    @Select("SELECT * FROM `ware` Where `wareID` = #{wareID}")
    Ware selectWareByID(int wareID);

    // 通过商品ID查询商品名称
    @Select("SELECT `wareName` FROM `ware` Where `wareID` = #{wareID}")
    String selectWareNameByID(int wareID);

    // 通过商品名称查询商品信息
    @Select("Select * From `ware` Where `wareName` = #{wareName}")
    Ware selectWareByName(String wareName);

    // 新增商品信息，并返回自增的wareID到传入的ware对象中
    @Insert("Insert `ware` set `wareType` = #{wareType}, `wareName` = #{wareName}")
    @Options(useGeneratedKeys = true, keyProperty = "wareID")
    void insertWare(Ware ware);

    // 删除商品
    @Delete("Delete From `ware` Where `wareID` = #{wareID}")
    boolean deleteWare(int wareID);


}
